<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>个人信息</title>
    <meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="Author" content="larry" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="../../statics/common/cascader/cascader/cascader.css" media="all">
<link rel="stylesheet" type="text/css" href="../../statics/common/layui/css/layui.css" media="all">
<link rel="stylesheet" type="text/css" href="../../statics/common/layui/css/autocomplete.css">
<link rel="stylesheet" type="text/css" href="../../statics/common/layui/css/soulTable.css">
<link rel="stylesheet" type="text/css" href="../../statics/plugins/ztree/css/metroStyle/metroStyle.css">
<link rel="stylesheet" type="text/css" href="../../statics/css/common.css">
<link rel="stylesheet" type="text/css" href="../../statics/css/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="../../statics/css/list-search-table.css">
<!--<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/layui-soul-table/docs/soulTable.css" media="all"/>-->
<script type="text/javascript" src="../../statics/plugins/jquery.min.js"></script>
<script type="text/javascript" src="../../statics/common/lib/vue.min.js"></script>
<script type="text/javascript" src="../../statics/plugins/ztree/jquery.ztree.all.min.js"></script>
<script type="text/javascript" src="../../statics/common/layui/layui.all.js"></script>
<script type="text/javascript" src="../../statics/common/js/axios.min.js"></script>
<script type="text/javascript" src="../../statics/common/js/xm-select.js"></script>
<script type="text/javascript" src="../../statics/js/common.js"></script>
<script type="text/javascript" src="../../statics/js/upload.js"></script>
<script type="text/javascript" src="../../statics/common/step/steps.js"></script>
<link rel="stylesheet" href="../../statics/css/jxcPublicAll.css"  media="all">
<link href="../../statics/common/photoviewer/dist/photoviewer.css" rel="stylesheet">
<link rel="stylesheet" href="../../statics/common/step/steps.css">
<!--<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.7/cropper.css" media="all">-->
<link rel="stylesheet" href="../../statics/js/modules/cropper/cropper.css" media="all">
<link rel="stylesheet" type="text/css" href="../../statics/css/viewer.min.css">
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/cropperjs/1.5.7/cropper.min.js"></script>-->
<script src="../../statics/js/modules/cropper/cropper.min.js"></script>
<script src="../../statics/common/photoviewer/dist/photoviewer.js"></script>
<script src="../../statics/common/layui/autocomplete.js"></script>
<script  src="../../statics/js/modules/viewer/viewer.min.js"></script>
<script src="../../statics/common/print-js/print.min.js"></script>
<link rel="stylesheet" type="text/css" href="../../statics/common/print-js/print.min.css">
<script type="text/javascript" src="../../statics/common/xmselect/xm-select.js"></script>
<script type="text/javascript" src="../../statics/js/searchview.js"></script>
<script type="text/javascript" src="../../statics/js/tableedit.js"></script>

<!--<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.0&type=webgl&ak=eo4XeZhRKHsQ0NOe6u6NkKscmRsk416B"></script>-->

<!-- 引入组件库 -->
<link rel="stylesheet" type="text/css" href="../../statics/css/index.css">






<!--    <link rel="stylesheet" type="text/css" href="../../statics/common/layui/css/layui.css" media="all">-->
    <style>
        .info-details {
            padding: 5px 0px;
            padding-top: 4px;
        }

        .vertical-align {
            display: flex;
            align-items: center;
        }

        .layui-upload-fileBox {
            border:1px solid #afafaf;
            width: 100px;
            height: 100px;
            line-height: 100px;
            text-align: center;
        }
        .layui-upload-fileBox .layui-icon {
            font-size: 30px;
        }
        .layui-upload-img {
            width: 100px;
            height: 100px;
        }

        .multiple-cell {
            display: table-cell;
            padding-right: 8px;
        }

        .multiple-table {
            margin-bottom: 9px;
            display: table;
        }

        .info-img{
            width: 50px;height: 50px;border-radius: 50%;margin-right: 10px;
        }
    </style>
</head>
<body>
<div id="app">
    <div style="">
        <form class="layui-form" action="">

            <div class="layui-form-item" :sid="sid">
                <label class="layui-form-label">头像：</label>
                <div class="layui-input-block">
                    <div class="multiple-table">
                        <div class="multiple-cell" v-show="sessionStorage.getItem('avatar') != null">
                            <img class="info-img" :src="imageURL + sessionStorage.getItem('avatar')" alt="">
                        </div>
                        <div class="multiple-cell" v-show="sessionStorage.getItem('avatar') == null">
                            <img class="info-img" src="/xz-admin/statics/images/user.jpg" alt="">
                        </div>
                        <div class="multiple-cell"style="padding-left: 50px">
                            <a class="layui-btn layui-btn-normal" id="editavatar">修改</a>
                        </div>
                    </div>

                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">用户名：</label>
                <div class="layui-input-block">

                    <div class="info-details">{{sysUserInfo.username}}</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label ">密码：</label>
                <div class="layui-input-block">
                    <button id="changePwd" type="button" class="layui-btn layui-btn-sm layui-btn-normal">修改密码</button>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">手机号：</label>
                <div class="layui-input-block">

                    <div class="info-details">{{sysUserInfo.mobile}}</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">邮箱：</label>
                <div class="layui-input-block">

                    <div class="info-details">{{sysUserInfo.email}}</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">所属部门：</label>
                <div class="layui-input-block">

                    <div class="info-details">{{sysUserInfo.deptName}}</div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">角色：</label>
                <div class="layui-input-block">

                    <div class="info-details">{{formatRoles(sysUserInfo.roles)}}</div>
                </div>
            </div>
           <!-- <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="formDemo">确认修改</button>
                </div>
            </div>-->
        </form>
    </div>
</div>
</body>
<!--<script type="text/javascript" src="../../statics/common/layui/layui.all.js"></script>-->
<!--<script type="text/javascript" src="../../statics/common/lib/vue.min.js"></script>-->
<script type="text/javascript" src="../../statics/js/common.js"></script>
<script type="text/javascript">
    $(function () {
        layui.config({
            base: '../../statics/common/'
        }).extend({
            soulTable: 'layui/soultable/ext/soulTable.slim'
        });
        layui.use(['form', 'layedit', 'laydate', 'element', 'table', 'soulTable'], function () {
            layui.upload.render({
                elem: '#editavatar',
                url: baseURL + 'sys/user/editavatar',
                data: {'path': 'useravatar'},
                field: 'files',
                auto: true,
                size: 30 * 1024 * 1024,
                accept: 'file', //普通文件
                acceptMime: '.jpg,.png,.jpeg',
                exts: 'jpg|png|jpeg', //
                multiple: true,
                number:20,
                choose: function (obj) {
                    PageLoading();
                },
                done: function (res) {
                    RemoveLoading();
                    if (res.code == '0') {
                        var url = res.data[0];
                        sessionStorage.setItem("avatar", url);
                        vm.sid = 'sid_'+uuid(32);
                        layer.msg('修改成功', {icon: 1});
                    } else {
                        layer.msg('上传失败', {icon: 5});
                    }
                },
                error: function () {
                    RemoveLoading();
                    layer.msg('上传失败', {icon: 5});
                }
            });
            layui.form.render();
        });
    });

    var vm = new Vue({
        el: '#app',
        data:{
            sysUserInfo: {
                username: '-',
                deptName: '-',
                roles: '-',
                mobile:'-',
                email:'-'
            },
            sid:'sid_0',
            unread:null,
        },
        created() {
            this.getSysUserInfo();
        },



        mounted(){
             console.log('dddddd ---------- ****************')
            layui.use('upload', function () {
                var $ = layui.jquery
                    , upload = layui.upload;
                //普通图片上传
                var uploadInst = upload.render({

                    elem: '#test1'
                    , url: 'https://httpbin.org/post' //改成您自己的上传接口
                    , before: function (obj) {
                        //预读本地文件示例，不支持ie8
                        obj.preview(function (index, file, result) {
                            $('#demo1').attr('src', result).show(); //图片链接（base64）
                            $('#fileAdd').hide()
                        });
                    }
                    , done: function (res) {
                        if (res.code > 0) {
                            return layer.msg('上传失败');
                        }
                        //上传成功
                    }
                    , error: function () {
                        //演示失败状态，并实现重传
                        var demoText = $('#demoText');
                        demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                        demoText.find('.demo-reload').on('click', function () {
                            uploadInst.upload();
                        });
                    }
                });

                // 修改密码
                $('#changePwd').click(function(){
                       var index = layer.open({
                        title: "修改个人密码",
                        type: 2,
                        area:['600px','400px'],
                        content: tabBaseURL+'modules/sys/updateUserPass.html',
                        success: function(layero,num){
                            var iframe = window['layui-layer-iframe'+num];
                            iframe.vm.indexUser = num;
                        },
                        end: function(){
                            layer.close(index);
                        }
                    });
                })
            });
        },

        methods:{
            formatRoles:function(roles){
                if(roles != null && roles != ''){
                    var roleArray=roles.split(",");
                    if( roleArray.length > 1){
                        return  roleArray[0]+"...";
                    }else{
                        return  roleArray[0];
                    }
                }
            },

            getSysUserInfo() {
                var _this = this;
                $.get(baseURL +'/workbench/workbench/sysuserinfo', function (r) {
                    if (null != r.sysUserInfo) {
                        _this.sysUserInfo = r.sysUserInfo;
                    }
                });
            }
        },

    })
</script>
</html>